<template>
	<view class="con" @scrolltolower="loadMore">
		
		<view class="goods">
			<view class="goodsli" v-for="(v,i) in goodsList" >
				<view class="goodsImg" @click="jump(v.id,v.product_name)">
					<image :src="v.preview_img" mode="aspectFit"></image>
					<view class="conmtypelitexts " v-if="v.product_bank_price">返现金额:{{v.product_bank_price}}</view>
				</view>
				<view class="goodstext" @click="jump(v.id,v.product_name)">{{v.product_name}}</view>
				<view class="goodsprice">
					<view class="goodspricetext">
						￥{{v.product_shop_price}}
					</view>
					
				</view>
			</view>
		</view>
		<!-- 滑动到底部触发加载更多 -->
		<view v-if="loading" class="zanwu">加载中...</view>
		<view v-if="noMoreData" class="zanwu">没有更多商品了</view>
		<!-- <view class="zanwu" v-if="zanwu">暂无更多数据</view> -->
		
	</view>
	
</template>

<script>
	import{getXgjBottomRecommendGoods} from '@/api/goodsList.js'
	export default {
		name: "sheetRecommend",
		props: {
			isType:{
				type:Number,
				default:1
			}
		},
		data() {
			return {
				goodsList:[],
				loading: false,   // 是否正在加载
			    noMoreData: false, // 是否还有更多数据
			    page: 1,          // 当前页
				pageSize: 10
				
			}
		},
		// number
		onShow() {
		
		},
		
		methods: {
			getRecommendlist(){
				if (this.loading || this.noMoreData) return;
				this.loading = true;
				let data = {
					type:this.isType
				}
				getXgjBottomRecommendGoods(data,this.page).then(res=>{
					this.loading = false;
					if (res.result.data.length < this.pageSize) {
						this.noMoreData = true; // 如果返回的数据小于每页大小，表示没有更多数据
					  }
					  this.goodsList = [...this.goodsList, ...res.result.data]; // 将新数据合并到现有数据中
					  this.page++; // 下一页
				}).catch(err=>{
					 this.loading = false;
					uni.showToast({
						title:err.msg,
						icon:'none'
					})
				})
			},
			// 滑动到底部加载更多
			loadMore() {
			  this.loadGoods();
			},
			jump(id,title){
				console.log('触发')
				uni.navigateTo({
					url:"/package/info/index?id="+ id +'&title='+title
					// url: '../info/index?id='+ id +'&title='+title
				});
			},
			
		}
	}
</script>

<style lang="scss">
	@import '@/package/goodsList/index.scss';
	.u-status-bar{
		display: none;
	}
</style>